/*
 * @Author: your name
 * @Date: 2021-01-25 20:27:02
 * @LastEditTime: 2021-01-25 23:38:09
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \ad-api\dao\contentDao.js
 */
const { querySql } = require('../db')
module.exports = {
   // 获取页面列表
  getContentDao: async (page_id) => {  
    const sql = page_id ? `select * from page_content where page_id='${page_id}'` :'select * from page_content'
    return await querySql(sql)
  }, 
 //添加页面内容
 async addContentDao({imgsInfo , page_id}) {
  let insertStr = ''
  imgsInfo.forEach(item => {
   insertStr += `('${item.name}','${item.imgPath}','${page_id}'),`
  })
  let sql = `insert into page_content (img_name, img_path , page_id) values ` + insertStr
  sql = sql.substr(0, sql.length - 1)
  return await querySql(sql)
 },
  //根据id删除图片
  delContentDao: async (img_id) => {
   const sql = `delete from page_content where id='${img_id}'`
   return await querySql(sql)
},
}